package com.maschinenstuermer.profiler.trace.presentation;

import org.eclipse.emf.common.notify.impl.AdapterImpl;

import com.maschinenstuermer.profiler.trace.Invocation;
import com.maschinenstuermer.profiler.trace.Metrics;
import com.maschinenstuermer.profiler.trace.provider.IRootInvocation;

public class RootInvocationAdapter extends AdapterImpl implements
		IRootInvocation {
	private Invocation root;
	
	public RootInvocationAdapter(Invocation root) {
		super();
		this.root = root;
	}

	@Override
	public boolean isAdapterForType(Object type) {
		return type == IRootInvocation.class;
	}
	
	@Override
	public Invocation getRoot() {
		return root;
	}

	@Override
	public double getRelativeTime(Metrics metrics) {
		final double relativeTime = ((double) metrics.getTotalTimeNs()) / root.getMetrics().getTotalTimeNs();
		return relativeTime;
	}
}
